﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Icinetic.FeedCategorySample.Common.Base;
using Icinetic.FeedCategorySample.Entities;
using Icinetic.FeedCategorySample.Services.Providers;
using Icinetic.FeedCategorySample.ViewModel;
using Windows.ApplicationModel.DataTransfer;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Security.Authentication.Web;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

namespace Icinetic.FeedCategorySample
{
    public sealed partial class ArticlePage : LayoutAwarePage
    {
        public ArticlePage()
        {
            this.InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            RssItem item = e.Parameter as RssItem;
            ArticlePageViewModel articlePageViewModel = new ArticlePageViewModel();
            
            articlePageViewModel.LoadFeedItem(item);
           
            base.OnNavigatedTo(e);

            this.DataContext = articlePageViewModel;
            HookSharing((DataTransferManager sender, DataRequestedEventArgs args) => articlePageViewModel.FillShareInfo(args.Request));
        }

        private void CompartirButton_Click(object sender, RoutedEventArgs e)
        {
            DataTransferManager.ShowShareUI();
        }
    }
}
